package com.spit.hkpost.api

import android.os.Bundle
import androidx.navigation.NavController
import androidx.navigation.NavOptions
import com.blankj.utilcode.util.ActivityUtils
import com.google.gson.Gson
import com.spit.hkpost.MainActivity
import com.spit.hkpost.R
import com.spit.hkpost.bean.DataBean
import com.spit.hkpost.ui.act.ZxingAct


/**
 * Created by Administrator on 2017/2/22.
 */

class UIHelper private constructor() {

    init {
        throw UnsupportedOperationException("u can't instantiate me...")
    }


    companion object {

        val navOptions = NavOptions.Builder()
            .setEnterAnim(R.anim.slide_in_right)  // 设置进入动画
            .setExitAnim(R.anim.slide_out_left)  // 设置退出动画
            .setPopEnterAnim(R.anim.slide_in_left)  // 设置返回动画
            .setPopExitAnim(R.anim.slide_out_right)  // 设置返回退出动画
            .build()

        fun startMainAct() {
            ActivityUtils.startActivity(MainActivity::class.java)
        }

        /**
         *  二维码
         */
        fun startZxingAct(type: Int) {
            val bundle = Bundle()
            bundle.putInt("type", type)
            ActivityUtils.startActivity(bundle, ZxingAct::class.java)
        }

        /**
         *  搜索 RFID
         */
        fun startSearchRfidFrg(nav: NavController, epc: String?, list: ArrayList<DataBean>) {
            val bundle = Bundle()
            bundle.putString("epc", epc)
            bundle.putString("list", Gson().toJson(list))
            nav.navigate(R.id.action_rfidParentFrg_to_searchRfidFrg, bundle, navOptions)
        }

    }
}

